package com.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 创建人   iscas-qd
 * 创建时间  13:20
 * ==============================================
 * 类说明：
 * <p/>
 * ==============================================
 * 修改记录
 * 修改人          修改时间             修改内容
 * 郭培辉          13:20             创建
 * ==============================================
 */
public class PropertiesUtils {
    private static Properties pros = null;//Properties Object

    /**
     * Loading files to Properties object
     * @param fileName
     */
    public static Properties load(String fileName){
        pros = new Properties();//Create a Properties object
        /**
         * Get properties file attributes for the current value
         * of the inter-class compiled bytecode
         * in file list of files of the documents
         * called fileName input stream
         */
        InputStream in = PropertiesUtils.class.getResourceAsStream(fileName);
        try {
            pros.load(in);//Load the file Properties to flow to the object
        } catch (IOException e) {
            e.printStackTrace();
        }
        return pros;
    }

    /**
     * Through the attribute name to get attribute values
     * @param key
     * @return
     */
    public static String get(String key){
        return pros.getProperty(key);//Through the key specific get attribute value
    }
}
